

var product_id = $('#hidden-product').val();

var sync_content = function() {
    $.ajax({
        url: '/weixin/delivery_in/get_moves',
        data: {'product_id': product_id},
        type: 'get',
        success: function(e) {
            var args = JSON.parse(e);
            delivery_in_vm.moves = args.moves;
            delivery_in_vm.product = args.product;
            delivery_in_vm.active_length = args.active_length;
        },
    });
};

var delivery_in_vm = avalon.define({
    $id: 'delivery-in',
    product: {},
    moves: [],
    active_length: 0,
    action_done: function(move) {
        $.ajax({
            url: '/weixin/delivery_in/action_done',
            data: {'move_id': move.id},
            type: 'post',
            success: function(e) {
                move.delete = true;
                delivery_in_vm.active_length -= 1;
            },
        });
    },
});

avalon.scan();

sync_content();
